define([
  'jquery',
  'underscore',
  'models/User',
  'views/Modal',
  'views/media/PhotoAlbumModal',
  'hbs!template/media/video-view-modal',
  'swfObject'
],function($, _, User, Modal, PhotoAlbumModal, template_modal){
  var VideoAlbumModal = PhotoAlbumModal.extend({
    type: "video",
    initialize: function(options) {
      options || (options = {});
      
      this.template = template_modal;

      this.models = options.models;
      this.position = options.position;
      _.bindAll(this, 'player');

      this.user = new User();
      this.user.fetch();
    },

    render: function() {
      this.renderContain();
      //this.player();
      $(this.el).modal({"show": false, keyboard: true, "data-backdrop": true, "backdrop": true});
      $(this.el).on("shown", this.player);
      return this;
    },
    
    player: function() {
      var params = { allowScriptAccess: "always" };
      var atts = { id: "ytPlayer" };

      swfobject.embedSWF(this.getURLContent(), "videoDiv", "530", "315", "9", null, null, params, atts);
    },

    getURLContent: function() {
      var videoID = this.models[this.position].id;
      return "http://www.youtube.com/v/" + videoID + "?version=3&enablejsapi=1&playerapiid=player1&autoplay=1";
    }
  });

  return VideoAlbumModal;
});
